package base.day24;

import java.io.*;
import java.util.ArrayList;

public class MyCharacterStream13 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("E:\\java\\java project\\java-code\\a.txt"));
        ArrayList<Student> list=new ArrayList<>();
        Student stu1=new Student("张三",19);
        Student stu2=new Student("李四",19);
        Student stu3=new Student("王五",19);

        list.add(stu1);
        list.add(stu2);
        list.add(stu3);

        oos.writeObject(list);

        ObjectInputStream ois=new ObjectInputStream(new FileInputStream("E:\\java\\java project\\java-code\\a.txt"));
        ArrayList<Student> list1 =(ArrayList<Student>) ois.readObject();
        for (Student student : list1) {
            System.out.println(student);
        }

    }
}
